package com.heima.controller;

import com.heima.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
public class UserController {

    @Resource
    private RestTemplate restTemplate;

    @Value("${user.userPath}")
    private String userPath;

    @GetMapping("/consumer/{id}")
    public User findById(@PathVariable Long id){
        //一共两种方式
        return this.restTemplate.getForObject(userPath+id,User.class);
    }
}
